﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace One_day.Areas.admin.Controllers
{
    public class BackStageController : Controller
    {
        // GET: admin/BackStage
        public ActionResult Index()
        {
            
            return View();
        }
        public JsonResult LoginCheck(String LoginName,String PWD)
        {
            One_day.Models.YichenEntities db = new Models.YichenEntities();
            
            if (db.T_Base_User.Where(m => m.LoginName == LoginName && m.PWD == PWD&&m.Type==2).ToList().Count()>0)
            {
                One_day.Models.T_Base_User user = db.T_Base_User.Where(m => m.LoginName == LoginName && m.PWD == PWD && m.Type == 2).ToList()[0];
                Session["admin"] = user;
                return Json(new { code = 1, message = "登陆成功" });
            }
            else
            {
                return Json(new { code = -1, message = "登陆失败，账号或密码错误" });
            }
        }
        public ActionResult Loginout()
        {
            
            Session["admin"] = null;
            return Redirect("/admin/backstage/index");
        }
    }
}